# Copyright (C) 2008-2025 GraphicsMagick Group

# This program is covered by multiple licenses, which are described in
# Copyright.txt. You should have received a copy of Copyright.txt with this
# package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
#
# Makefile for building HTML files
#

WWWDIR=$(top_srcdir)/www

# Install HTML files
DOCDIRS = www www/api www/images www/Magick++ www/wand
HTML_INSTALL_DATA_TARGETS = install-data-html
install-data-html:
	$(mkinstalldirs) $(DESTDIR)$(htmldir)
	@for dir in $(DOCDIRS) ; do \
	  $(mkinstalldirs) $(DESTDIR)$(htmldir)/$$dir && \
	  for file in $(srcdir)/$$dir/*.* ; do \
            case $$file in \
              *.c | *.css | *.gif | *.html | *.ico | *.jpg | *.png ) \
	        echo "$(INSTALL_DATA) $$file $(DESTDIR)$(htmldir)/$$dir" ; \
	        $(INSTALL_DATA) "$$file" $(DESTDIR)$(htmldir)/$$dir ; \
                ;; \
            esac \
	  done ; \
	done

# Uninstall HTML files
HTML_UNINSTALL_DATA_TARGETS = uninstall-data-html
#	rm -f $(DESTDIR)$(htmldir)/index.html
uninstall-data-html:
	for dir in $(DOCDIRS) ; do \
	  rm -f -r $(DESTDIR)$(htmldir)/$$dir ; \
	done

# These files are built from reStructuredText
RST2HTML_TARGETS = \
	$(WWWDIR)/ChangeLog-2001.html \
	$(WWWDIR)/ChangeLog-2002.html \
	$(WWWDIR)/ChangeLog-2003.html \
	$(WWWDIR)/ChangeLog-2004.html \
	$(WWWDIR)/ChangeLog-2005.html \
	$(WWWDIR)/ChangeLog-2006.html \
	$(WWWDIR)/ChangeLog-2007.html \
	$(WWWDIR)/ChangeLog-2008.html \
	$(WWWDIR)/ChangeLog-2009.html \
	$(WWWDIR)/ChangeLog-2010.html \
	$(WWWDIR)/ChangeLog-2011.html \
	$(WWWDIR)/ChangeLog-2012.html \
	$(WWWDIR)/ChangeLog-2013.html \
	$(WWWDIR)/ChangeLog-2014.html \
	$(WWWDIR)/ChangeLog-2015.html \
	$(WWWDIR)/ChangeLog-2016.html \
	$(WWWDIR)/ChangeLog-2017.html \
	$(WWWDIR)/ChangeLog-2018.html \
	$(WWWDIR)/ChangeLog-2019.html \
	$(WWWDIR)/ChangeLog-2020.html \
	$(WWWDIR)/ChangeLog-2021.html \
	$(WWWDIR)/ChangeLog-2022.html \
	$(WWWDIR)/ChangeLog-2023.html \
	$(WWWDIR)/ChangeLog-2024.html \
	$(WWWDIR)/ChangeLog.html \
	$(WWWDIR)/Changes.html \
	$(WWWDIR)/Copyright.html \
	$(WWWDIR)/FAQ.html \
	$(WWWDIR)/Hg.html \
	$(WWWDIR)/INSTALL-unix.html \
	$(WWWDIR)/INSTALL-windows.html \
	$(WWWDIR)/ImageMagickObject.html \
	$(WWWDIR)/Magick++/Blob.html \
	$(WWWDIR)/Magick++/ChangeLog.html \
	$(WWWDIR)/Magick++/CoderInfo.html \
	$(WWWDIR)/Magick++/Color.html \
	$(WWWDIR)/Magick++/Drawable.html \
	$(WWWDIR)/Magick++/Enumerations.html \
	$(WWWDIR)/Magick++/Exception.html \
	$(WWWDIR)/Magick++/FormatCharacters.html \
	$(WWWDIR)/Magick++/Geometry.html \
	$(WWWDIR)/Magick++/Image.html \
	$(WWWDIR)/Magick++/ImageDesign.html \
	$(WWWDIR)/Magick++/Montage.html \
	$(WWWDIR)/Magick++/PixelPacket.html \
	$(WWWDIR)/Magick++/Pixels.html \
	$(WWWDIR)/Magick++/TypeMetric.html \
	$(WWWDIR)/Magick++/index.html \
	$(WWWDIR)/NEWS.html \
	$(WWWDIR)/OpenMP.html \
	$(WWWDIR)/README.html \
	$(WWWDIR)/api/api.html \
	$(WWWDIR)/authors.html \
	$(WWWDIR)/benchmarks.html \
	$(WWWDIR)/bugs.html \
	$(WWWDIR)/contribute.html \
	$(WWWDIR)/download.html \
	$(WWWDIR)/formats.html \
	$(WWWDIR)/index.html \
	$(WWWDIR)/links.html \
	$(WWWDIR)/miff.html \
	$(WWWDIR)/mission.html \
	$(WWWDIR)/motion-picture.html \
	$(WWWDIR)/perl.html \
	$(WWWDIR)/process.html \
	$(WWWDIR)/programming.html \
	$(WWWDIR)/project.html \
	$(WWWDIR)/quantize.html \
	$(WWWDIR)/reference.html \
	$(WWWDIR)/security.html \
	$(WWWDIR)/thanks.html \
	$(WWWDIR)/tools.html \
	$(WWWDIR)/utilities.html \
	$(WWWDIR)/wand/wand.html

# These files are existing reStructuredText files
WWW_RST_FILES = \
	$(WWWDIR)/Changes.rst \
	$(WWWDIR)/FAQ.rst \
	$(WWWDIR)/Hg.rst \
	$(WWWDIR)/ImageMagickObject.rst \
	$(WWWDIR)/Magick++/Blob.rst \
	$(WWWDIR)/Magick++/CoderInfo.rst \
	$(WWWDIR)/Magick++/Color.rst \
	$(WWWDIR)/Magick++/Drawable.rst \
	$(WWWDIR)/Magick++/Enumerations.rst \
	$(WWWDIR)/Magick++/Exception.rst \
	$(WWWDIR)/Magick++/FormatCharacters.rst \
	$(WWWDIR)/Magick++/Geometry.rst \
	$(WWWDIR)/Magick++/Image.rst \
	$(WWWDIR)/Magick++/ImageDesign.rst \
	$(WWWDIR)/Magick++/Montage.rst \
	$(WWWDIR)/Magick++/PixelPacket.rst \
	$(WWWDIR)/Magick++/Pixels.rst \
	$(WWWDIR)/Magick++/TypeMetric.rst \
	$(WWWDIR)/Magick++/index.rst \
	$(WWWDIR)/OpenMP.rst \
	$(WWWDIR)/api/api.rst \
	$(WWWDIR)/authors.rst \
	$(WWWDIR)/benchmarks.rst \
	$(WWWDIR)/bugs.rst \
	$(WWWDIR)/contribute.rst \
	$(WWWDIR)/download.rst \
	$(WWWDIR)/formats.rst \
	$(WWWDIR)/index.rst \
	$(WWWDIR)/links.rst \
	$(WWWDIR)/miff.rst \
	$(WWWDIR)/mission.rst \
	$(WWWDIR)/motion-picture.rst \
	$(WWWDIR)/perl.rst \
	$(WWWDIR)/process.rst \
	$(WWWDIR)/programming.rst \
	$(WWWDIR)/project.rst \
	$(WWWDIR)/quantize.rst \
	$(WWWDIR)/reference.rst \
	$(WWWDIR)/security.rst \
	$(WWWDIR)/thanks.rst \
	$(WWWDIR)/tools.rst \
	$(WWWDIR)/utilities.rst

# These are the HTML files which are packaged
WWW_HTML_FILES = \
	$(WWWDIR)/ChangeLog-2001.html \
	$(WWWDIR)/ChangeLog-2002.html \
	$(WWWDIR)/ChangeLog-2003.html \
	$(WWWDIR)/ChangeLog-2004.html \
	$(WWWDIR)/ChangeLog-2005.html \
	$(WWWDIR)/ChangeLog-2006.html \
	$(WWWDIR)/ChangeLog-2007.html \
	$(WWWDIR)/ChangeLog-2008.html \
	$(WWWDIR)/ChangeLog-2009.html \
	$(WWWDIR)/ChangeLog-2010.html \
	$(WWWDIR)/ChangeLog-2011.html \
	$(WWWDIR)/ChangeLog-2012.html \
	$(WWWDIR)/ChangeLog-2013.html \
	$(WWWDIR)/ChangeLog-2014.html \
	$(WWWDIR)/ChangeLog-2015.html \
	$(WWWDIR)/ChangeLog-2016.html \
	$(WWWDIR)/ChangeLog-2017.html \
	$(WWWDIR)/ChangeLog-2018.html \
	$(WWWDIR)/ChangeLog-2019.html \
	$(WWWDIR)/ChangeLog-2020.html \
	$(WWWDIR)/ChangeLog-2021.html \
	$(WWWDIR)/ChangeLog-2022.html \
	$(WWWDIR)/ChangeLog-2023.html \
	$(WWWDIR)/ChangeLog-2024.html \
	$(WWWDIR)/ChangeLog.html \
	$(WWWDIR)/Changes.html \
	$(WWWDIR)/Copyright.html \
	$(WWWDIR)/FAQ.html \
	$(WWWDIR)/GraphicsMagick.html \
	$(WWWDIR)/Hg.html \
	$(WWWDIR)/INSTALL-unix.html \
	$(WWWDIR)/INSTALL-windows.html \
	$(WWWDIR)/ImageMagickObject.html \
	$(WWWDIR)/ImageMagickObject.rst \
	$(WWWDIR)/Magick++/Blob.html \
	$(WWWDIR)/Magick++/ChangeLog.html \
	$(WWWDIR)/Magick++/CoderInfo.html \
	$(WWWDIR)/Magick++/Color.html \
	$(WWWDIR)/Magick++/Drawable.html \
	$(WWWDIR)/Magick++/Enumerations.html \
	$(WWWDIR)/Magick++/Exception.html \
	$(WWWDIR)/Magick++/FormatCharacters.html \
	$(WWWDIR)/Magick++/Geometry.html \
	$(WWWDIR)/Magick++/Image.html \
	$(WWWDIR)/Magick++/ImageDesign.html \
	$(WWWDIR)/Magick++/Montage.html \
	$(WWWDIR)/Magick++/PixelPacket.html \
	$(WWWDIR)/Magick++/Pixels.html \
	$(WWWDIR)/Magick++/TypeMetric.html \
	$(WWWDIR)/Magick++/index.html \
	$(WWWDIR)/NEWS.html \
	$(WWWDIR)/OpenMP.html \
	$(WWWDIR)/README.html \
	$(WWWDIR)/animate.html \
	$(WWWDIR)/api/api.html \
	$(WWWDIR)/authors.html \
	$(WWWDIR)/benchmarks.html \
	$(WWWDIR)/bugs.html \
	$(WWWDIR)/color.html \
	$(WWWDIR)/compare.html \
	$(WWWDIR)/composite.html \
	$(WWWDIR)/conjure.html \
	$(WWWDIR)/contribute.html \
	$(WWWDIR)/convert.html \
	$(WWWDIR)/display.html \
	$(WWWDIR)/docutils-api.css \
	$(WWWDIR)/docutils-articles.css \
	$(WWWDIR)/download.html \
	$(WWWDIR)/formats.html \
	$(WWWDIR)/gm.html \
	$(WWWDIR)/identify.html \
	$(WWWDIR)/import.html \
	$(WWWDIR)/index.html \
	$(WWWDIR)/links.html \
	$(WWWDIR)/miff.html \
	$(WWWDIR)/mission.html \
	$(WWWDIR)/mogrify.html \
	$(WWWDIR)/montage.html \
	$(WWWDIR)/motion-picture.html \
	$(WWWDIR)/perl.html \
	$(WWWDIR)/process.html \
	$(WWWDIR)/programming.html \
	$(WWWDIR)/project.html \
	$(WWWDIR)/quantize.html \
	$(WWWDIR)/reference.html \
	$(WWWDIR)/security.html \
	$(WWWDIR)/thanks.html \
	$(WWWDIR)/tools.html \
	$(WWWDIR)/utilities.html\
	$(WWWDIR)/wand/wand.html

WWW_EXTRA_DIST=$(WWW_HTML_FILES) $(WWW_RST_FILES)

WWW_MAINTAINER_TARGETS=$(WWW_HTML_FILES) $(WWWDIR)/color.html

if MAINTAINER_MODE

NAMED_COLORS=$(top_srcdir)/scripts/named_colors.py
RST2HTML5=$(top_srcdir)/scripts/rst2html5.py
RELPATH=$(top_srcdir)/scripts/relpath.py
OMP_DECIMAL_ALIGN=$(top_srcdir)/scripts/omp_decimal_align.py

$(RST2HTML_TARGETS) : \
	$(top_srcdir)/scripts/html_fragments.py \
	$(top_srcdir)/scripts/rst2html5.py \
	$(top_srcdir)/scripts/omp_decimal_align.py \
	$(WWWDIR)/Makefile.am

# Build HTML version of RST file (with "txt" extension)
$(top_srcdir)/www/%.html: $(top_srcdir)/%.txt
	@printf "Updating $@ ...\n"
	$(RST2HTML5) --stylesheet=`$(RELPATH) $(top_srcdir)/www $@`docutils-articles.css --url-prefix=`$(RELPATH) $(top_srcdir)/www $@` $<  > $@

# Build HTML version of RST file
$(top_srcdir)/%.html: $(top_srcdir)/%.rst
	@printf "Updating $@ ...\n"
	$(RST2HTML5)  --stylesheet=`$(RELPATH) $(top_srcdir)/www $@`docutils-articles.css --url-prefix=`$(RELPATH) $(top_srcdir)/www $@` $<  | $(OMP_DECIMAL_ALIGN) > $@

#
# Build HTML version of ChangeLogs
#
CHANGELOG2RST=$(top_srcdir)/scripts/changelog2rst.sh

$(top_srcdir)/www/ChangeLog.rst: $(top_srcdir)/ChangeLog
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog' < $^ > $@

$(top_srcdir)/www/ChangeLog-2024.rst: $(top_srcdir)/ChangeLog.2024
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2024' < $^ > $@

$(top_srcdir)/www/ChangeLog-2023.rst: $(top_srcdir)/ChangeLog.2023
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2023' < $^ > $@

$(top_srcdir)/www/ChangeLog-2022.rst: $(top_srcdir)/ChangeLog.2022
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2022' < $^ > $@

$(top_srcdir)/www/ChangeLog-2021.rst: $(top_srcdir)/ChangeLog.2021
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2021' < $^ > $@

$(top_srcdir)/www/ChangeLog-2020.rst: $(top_srcdir)/ChangeLog.2020
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2020' < $^ > $@

$(top_srcdir)/www/ChangeLog-2019.rst: $(top_srcdir)/ChangeLog.2019
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2019' < $^ > $@

$(top_srcdir)/www/ChangeLog-2018.rst: $(top_srcdir)/ChangeLog.2018
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2018' < $^ > $@

$(top_srcdir)/www/ChangeLog-2017.rst: $(top_srcdir)/ChangeLog.2017
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2017' < $^ > $@

$(top_srcdir)/www/ChangeLog-2016.rst: $(top_srcdir)/ChangeLog.2016
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2016' < $^ > $@

$(top_srcdir)/www/ChangeLog-2015.rst: $(top_srcdir)/ChangeLog.2015
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2015' < $^ > $@

$(top_srcdir)/www/ChangeLog-2014.rst: $(top_srcdir)/ChangeLog.2014
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2014' < $^ > $@

$(top_srcdir)/www/ChangeLog-2013.rst: $(top_srcdir)/ChangeLog.2013
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2013' < $^ > $@

$(top_srcdir)/www/ChangeLog-2012.rst: $(top_srcdir)/ChangeLog.2012
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2012' < $^ > $@

$(top_srcdir)/www/ChangeLog-2011.rst: $(top_srcdir)/ChangeLog.2011
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2011' < $^ > $@

$(top_srcdir)/www/ChangeLog-2010.rst: $(top_srcdir)/ChangeLog.2010
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2010' < $^ > $@

$(top_srcdir)/www/ChangeLog-2009.rst: $(top_srcdir)/ChangeLog.2009
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2009' < $^ > $@

$(top_srcdir)/www/ChangeLog-2008.rst: $(top_srcdir)/ChangeLog.2008
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2008' < $^ > $@

$(top_srcdir)/www/ChangeLog-2007.rst: $(top_srcdir)/ChangeLog.2007
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2007' < $^ > $@

$(top_srcdir)/www/ChangeLog-2006.rst: $(top_srcdir)/ChangeLog.2006
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2006' < $^ > $@

$(top_srcdir)/www/ChangeLog-2005.rst: $(top_srcdir)/ChangeLog.2005
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2005' < $^ > $@

$(top_srcdir)/www/ChangeLog-2004.rst: $(top_srcdir)/ChangeLog.2004
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2004' < $^ > $@

$(top_srcdir)/www/ChangeLog-2003.rst: $(top_srcdir)/ChangeLog.2003
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2003' < $^ > $@

$(top_srcdir)/www/ChangeLog-2002.rst: $(top_srcdir)/ChangeLog.2002
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2002' < $^ > $@

$(top_srcdir)/www/ChangeLog-2001.rst: $(top_srcdir)/ChangeLog.2001
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'GraphicsMagick ChangeLog - 2001' < $^ > $@

$(top_srcdir)/www/Magick++/ChangeLog.rst: $(top_srcdir)/Magick++/ChangeLog
	@printf "Updating $@ ...\n"
	$(CHANGELOG2RST) 'Magick++ ChangeLog' < $^ > $@

# Build color.html
$(WWWDIR)/color.html : $(NAMED_COLORS)
	@printf "Updating $@ ...\n"
	$(NAMED_COLORS) > $@

endif # MAINTAINER_MODE
